package com.yp.infrastructure.axon.interceptor;

import com.yp.infrastructure.common.exception.BaseException;
import org.axonframework.commandhandling.CommandMessage;

/**
 * 处此处理CommandHandler标签下的命令是否可以执行，所有模块必须有此接口的实现类
 */
public interface IAxonCommandHandlerInterceptor {


    /**
     * Command Message Handler Interceptor {@link com.yp.infrastructure.axon.interceptor.command.CmdMessageHandlerInterceptor}
     * @param payload command message
     * @throws BaseException .
     */
    default void onCommandMessageHandlerInterceptor(Object payload) throws BaseException {
    }


    /**
     * Command Message Dispatcher Interceptor {@link com.yp.infrastructure.axon.interceptor.command.CmdMessageDispatcherInterceptor}
     * @param payload command message
     * @throws BaseException .
     */
    default void onCommandMessageDispatcherInterceptor(Object payload) throws BaseException {

    }



    /**
     * Command Message Enhanced Definition Interceptor {@link com.yp.infrastructure.axon.interceptor.command.CmdMessageHandlerInterceptor}
     * @param commandMessage command message
     * @throws BaseException .
     */

    default boolean onCommandHandlerEnhancedDefinitionInterceptor(CommandMessage<?> commandMessage) throws BaseException {
        return true;
    }
}